package com.dyypdadmin.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dyypdadmin.pojo.vo.AppointmentRecordsDetail;
import com.dyypdadmin.pojo.vo.ServiceRecordsDetails;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ServiceRecordsDetailsDao extends BaseMapper<ServiceRecordsDetails> {
    //多表连接查询所有的信息
    @Select("select servicerecord_id,s.user_id,username,order_number,pet_name,appointment_id,service_name,complete_time,s.status,s.is_del,s.is_medical from servicerecords s join users u on u.user_id = s.user_id join pets p on s.pet_id = p.pet_id join servicedetails ss on s.project_id = ss.service_detail_id ")
    List<ServiceRecordsDetails> getAllDetails();

    //根据用户id查询所有服务记录
    @Select("select servicerecord_id,s.user_id,username,order_number,pet_name,appointment_id,service_name,complete_time,s.status,s.is_del,s.is_medical from servicerecords s join users u on u.user_id = s.user_id join pets p on s.pet_id = p.pet_id join servicedetails ss on s.project_id = ss.service_detail_id where p.user_id =#{user_id}")
    List<ServiceRecordsDetails> getAllDetailsByUserId(@Param("user_id")Integer user_id);


}
